/* 基础样式重置与布局 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-color: #f5f5f5;
}

/* 顶部标题栏 */
#header {
    padding: 15px;
    background-color: #2c3e50;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    /* 防止头部被压缩 */
}

#title {
    font-weight: bold;
}

#toggle-toc {
    background: none;
    border: 1px solid #fff;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}

#toggle-toc:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 主内容区布局 */
#main {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

/* 侧边目录栏 */
#sidebar {
    position: fixed;
    top: 63px;
    /* 从顶部开始 */
    bottom: 0;
    /* 到底部结束 —— 关键！让 sidebar 占满垂直空间 */
    width: 300px;
    background-color: #f0f0f0;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 10px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    z-index: 50;
}

#sidebar.hidden {
    width: 0;
    padding: 0;
    border-right: none;
    /* 可选：完全隐藏 overflow，避免滚动条残留 */
    /* overflow: hidden; */
}

#toc ul {
    list-style: none;
}

#toc li {
    padding: 5px 0;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

#toc li a {
    color: #333;
    text-decoration: none;
    display: block;
    padding: 5px;
    border-radius: 3px;
}

#toc li a:hover {
    background-color: #e0e0e0;
}

/* 阅读器视图区域 */
#viewer {
    flex-grow: 1;
    position: relative;
    background-color: #fff;
    /* 提供干净的阅读背景 */
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    /* 隐藏 iframe 可能产生的滚动条 */
    display: flex;
    justify-content: center;
    max-width: 1000px;
    margin: 0 auto;
}

/* 翻页按钮 (可根据需要显示/隐藏) */
.arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    color: #aaa;
    cursor: pointer;
    user-select: none;
    z-index: 10;
    background: rgba(255, 255, 255, 0.8);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#prev {
    left: 20px;
}

#next {
    right: 20px;
}

#viewer:hover .arrow {
    opacity: 0.7;
}

.arrow:hover {
    opacity: 1 !important;
    color: #555;
}

/* 加载指示器 */
#loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* 错误提示 */
#error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffebee;
    color: #c62828;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}